<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>医疗诊断结果</title>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
    <style type="text/css">
        .layui-form-label {
            width: 90px;
        }

        .layui-input-block {
            margin-left: 120px;
        }

    </style>
</head>
<body>
<div class="layui-container" style="width: 100%;">
    <div class="layui-row"></div>
    <div class="layui-row">
        <form class="layui-form" id="form1" lay-filter="form1">
            <input type="hidden" id="doctorId" name="doctorId">
            <div class="layui-form-item">
                <label for="objId" class="layui-form-label">工单id</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="objId" name="objId" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="doctorName" class="layui-form-label">诊断医生</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="doctorName" name="doctorName" readonly>
                </div>
                <label for="orderTime" class="layui-form-label">预约时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="orderTime" name="orderTime" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="status" class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <select id="status" name="status" readonly class="layui-form-select" disabled>
                        <option value="01">待审核</option>
                        <option value="02">审核通过</option>
                        <option value="03">审核不通过</option>
                        <option value="04">已完结</option>
                    </select>
                </div>
                <label for="createTime" class="layui-form-label">发起时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="createTime" name="createTime" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="userAccount" class="layui-form-label">病人身份证号</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="userAccount" name="userAccount" readonly>
                </div>
                <label for="userName" class="layui-form-label">病人名</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="userName" name="userName" readonly>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="careResult" class="layui-form-label">治疗结果</label>
                <div class="layui-input-block">
                    <textarea type="text" class="layui-textarea" id="careResult" name="careResult"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="carePropose" class="layui-form-label">治疗建议</label>
                <div class="layui-input-block">
                    <textarea type="text" class="layui-textarea" id="carePropose" name="carePropose"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="isOperation" class="layui-form-label">是否需要手术</label>
                <div class="layui-input-inline">
                    <select id="isOperation" name="isOperation" class="layui-form-select">
                        <option value="是">是</option>
                        <option value="否" selected>否</option>
                    </select>
                </div>
                <label for="operationTime" class="layui-form-label">手术时间</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="operationTime" name="operationTime" autocomplete="off">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="isBed" class="layui-form-label">是否需要住院</label>
                <div class="layui-input-inline">
                    <select id="isBed" name="isBed" class="layui-form-select">
                        <option value="是">是</option>
                        <option value="否" selected>否</option>
                    </select>
                </div>
                <label for="bed" class="layui-form-label">床位</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="bed" name="bed">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="cost" class="layui-form-label">诊断费</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="cost" name="cost" autocomplete="off">
                </div>
                <div class="layui-form-mid">元</div>
            </div>
            <div class="layui-form-item">
                <label for="remark" class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <textarea type="text" class="layui-textarea" id="remark" name="remark"></textarea>
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center;">
                <button type="button" class="layui-btn " onclick="finishOrder()" id="finish">完结</button>
                <button type="button" class="layui-btn layui-bg-gray" onclick="myPrint()">打印</button>
            </div>
        </form>
    </div>
    <div class="layui-row"></div>
</div>
</body>
<script type="text/javascript" src="../../static/layui/layui.all.js"></script>
<script type="text/javascript" src="../../static/config.js"></script>
<script type="text/javascript">
    const $ = layui.$;
    const element = layui.element;
    const layer = layui.layer;
    const form = layui.form;
    const table = layui.table;
    const laydate = layui.laydate;

    laydate.render({
        elem: "#operationTime",
        type: "datetime",
        min: 0,
        position: "fixed"
    });

    const obj = getUrlParams();
    console.log(obj);

    $.post({
        url: baseUrl + "/hospital-doctor/order/getOrderById",
        data: {
            objId: obj.objId
        },
        success: function (res) {
            console.log(res);
            form.val('form1', res.data);
            const objId = $("#objId");
            //转大写
            objId.val(objId.val().toUpperCase());
            if (res.data.status !== "02") {
                const finish = $("#finish");
                finish.removeAttr("onclick");
                finish.addClass("layui-btn-disabled");
            }
        }
    });

    function myPrint() {
        window.print();
    }

    function finishOrder() {
        const form1 = form.val('form1');
        console.log(form1);
        $.post({
            url: baseUrl + "/hospital-doctor/order/update",
            data: form1
        });
        //关闭
        const index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }

</script>
</html>